package com.dc.refactoring._1_重新组织函数._8_ReplaceMethodWithMethodObject;

/**
 * Description: 以函数对象取代函数
 * @author: gdc
 * @date: 2020/11/13
 * @version 1.0
 */
public class Account {

    /**
     * 改造前
     */
    public int gammaOld(int inputVal, int quantity, int yearToDate) {
        int importantValue1 = (inputVal * quantity) + delta();
        int importantValue2 = (inputVal * yearToDate) + 100;

        // 想要提炼的逻辑
        if ((yearToDate - importantValue1) > 200) {
            importantValue2 -= 20;
        }

        int importantValue3 = importantValue2 * 7;
        return importantValue3 - 2 * importantValue1;
    }

    /**
     * 改造后
     */
    public int gammaNew(int inputVal, int quantity, int yearToDate) {
        return new Gamma(this, inputVal, quantity, yearToDate).compute();
    }


    public int delta() {
        return 0;
    }
}
